<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24"> </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->

    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <a-button @click="handleAdd" type="primary" icon="plus" v-has="'BisAppletChannelController:add'">{{$t('新增')}}</a-button>
    </div>

    <!-- table区域-begin -->
    <div>
      <a-table
        ref="table"
        size="middle"
        :scroll="{ x: true }"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        class="j-table-force-nowrap"
        @change="handleTableChange"
      >
        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="imgSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px; font-style: italic">{{ $t('无图片') }}</span>
          <img
            v-else
            :src="getImgView(text)"
            height="25px"
            alt=""
            style="max-width: 80px; font-size: 12px; font-style: italic"
          />
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px; font-style: italic">{{ $t('无文件') }}</span>
          <a-button v-else :ghost="true" type="primary" icon="download" size="small" @click="downloadFile(text)">
            {{ $t('下载') }}
          </a-button>
        </template>

        <span slot="action" slot-scope="text, record">
          <a @click="handleEdit(record)" v-has="'BisAppletChannelController:edit'">{{ $t('编辑') }}</a>
          <a-popconfirm :title="$t('确定删除吗?')" @confirm="() => handleDelete(record.id)">
            <a v-has="'BisAppletChannelController:delete'" v-if="record.channel == '6'" style="margin-left: 8px">{{$t('删除')}}</a>
          </a-popconfirm>
        </span>
      </a-table>
    </div>

    <bis-applet-channel-modal ref="modalForm" @ok="modalFormOk"></bis-applet-channel-modal>
  </a-card>
</template>

<script>
import '@/assets/less/TableExpand.less'
import { mixinDevice } from '@/utils/mixin'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import BisAppletChannelModal from './modules/BisAppletChannelModal'
import { filterMultiDictText } from '@/components/dict/JDictSelectUtil'

export default {
  name: 'BisAppletChannelList',
  mixins: [JeecgListMixin, mixinDevice],
  components: {
    BisAppletChannelModal,
  },
  data() {
    return {
      description: '渠道管理管理页面',
      // 表头
      columns: [
        {
          title: this.$t('排序序号'),
          align: 'center',
          sorter: true,
          dataIndex: 'sort',
        },
        {
          title: this.$t('频道名称'),
          align: 'center',
          dataIndex: 'name',
        },
        {
          title: this.$t('频道类型'),
          align: 'center',
          dataIndex: 'channel_dictText',
        },
        {
          title: this.$t('状态'),
          align: 'center',
          dataIndex: 'state_dictText',
        },
        {
          title: this.$t('频道图标'),
          align: 'center',
          dataIndex: 'picture',
          scopedSlots: { customRender: 'imgSlot' },
        },
        {
          title: this.$t('说明'),
          align: 'center',
          dataIndex: 'intro',
        },
        {
          title: this.$t('操作'),
          dataIndex: 'action',
          align: 'center',
          fixed: 'right',
          width: 147,
          scopedSlots: { customRender: 'action' },
        },
      ],
      url: {
        list: '/applet/bisAppletChannel/list',
        delete: '/applet/bisAppletChannel/delete',
        deleteBatch: '/applet/bisAppletChannel/deleteBatch',
        exportXlsUrl: '/applet/bisAppletChannel/exportXls',
        importExcelUrl: 'applet/bisAppletChannel/importExcel',
      },
      dictOptions: {},
      superFieldList: [],
      /* 排序参数 */
      isorter: {
        column: 'sort',
        order: 'ASC',
      },
    }
  },
  created() {
    this.getSuperFieldList()
  },
  computed: {
    importExcelUrl: function () {
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`
    },
  },
  methods: {
    handleAdd(){
      this.$refs.modalForm.add({channel: 6,jumpType: 0,});
      this.$refs.modalForm.title = this.$t('新增');
      this.$refs.modalForm.disableSubmit = false;
    },
    initDictConfig() {},
    getSuperFieldList() {
      let fieldList = []
      fieldList.push({ type: 'int', value: 'sort', text: '排序序号', dictCode: '' })
      fieldList.push({ type: 'int', value: 'channel', text: '频道名称', dictCode: 'bis_applet_channel.channel' })
      fieldList.push({ type: 'int', value: 'state', text: '状态', dictCode: '' })
      fieldList.push({ type: 'string', value: 'picture', text: '频道图标', dictCode: '' })
      this.superFieldList = fieldList
    },
  },
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>